package com.coding.asp;

import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.context.annotation.EnableAspectJAutoProxy;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Component;

/**
 * @author Cynicism
 * @version 1.0
 * @project DyApp
 * @description
 * @date 2024/7/7 17:40:09
 */
@EnableAspectJAutoProxy
@Component
@Aspect
@Slf4j
public class LogAspect {

    /**
     * define point cut.
     */
    @Pointcut("execution(* com.coding.service.*.*(..))")
    private void pointCutMethod() {
    }


    @Around("pointCutMethod()")
    public Object doAround(ProceedingJoinPoint pjp) throws Throwable {
        System.out.println("-----------------------");
        log.info("方法名：{}, 方法参数：{}",pjp.getSignature().getName(), pjp.getArgs());
        Object o = pjp.proceed();
        log.info("返回值：{}", o);
        return o;
    }
}
